%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/polymorphic/vulns-ordering"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 13, 21, 11<br />2: PgUnionAll[8]<br />3: Connection[12]<br />4: ConnectionItems[14]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 12, 21, 14, 11<br /><br />ROOT Connectionᐸ8ᐳ[12]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 21, 11<br /><br />ROOT __Item{3}ᐸ14ᐳ[17]"):::bucket
    Bucket4("Bucket 4 (polymorphic)<br />__typename: Access[24]<br />Deps: 24, 11, 25"):::bucket
    Bucket5("Bucket 5 (polymorphicPartition)<br />|FirstPartyVulnerability<br />Deps: 11, 25<br />ᐳFirstPartyVulnerability<br /><br />1: PgSelect[26]<br />2: PgSelectRows[31]<br />ᐳ: 30, 32, 41, 43, 45"):::bucket
    Bucket6("Bucket 6 (polymorphicPartition)<br />|ThirdPartyVulnerability<br />Deps: 11, 25<br />ᐳThirdPartyVulnerability<br /><br />1: PgSelect[34]<br />2: PgSelectRows[39]<br />ᐳ: 38, 40, 42, 44, 46, 47, 49"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5 & Bucket6

    %% plan dependencies
    PgUnionAll8[["PgUnionAll[8∈0] ➊<br />ᐸFirstPartyVulnerability,ThirdPartyVulnerabilityᐳ<br />More deps:<br />- Object[11]<br />- Constantᐸ[Function: applyInputConstant]ᐳ[13]"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 3"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    Connection12[["Connection[12∈0] ➊<br />ᐸ8ᐳ"]]:::plan
    PgUnionAll8 --> Connection12
    ConnectionItems14[["ConnectionItems[14∈0] ➊"]]:::plan
    Connection12 --> ConnectionItems14
    List22{{"List[22∈3]<br />ᐸ19,20,21ᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[21]"}}:::plan
    Access19{{"Access[19∈3]<br />ᐸ17.0ᐳ"}}:::plan
    Access20{{"Access[20∈3]<br />ᐸ17.1ᐳ"}}:::plan
    Access19 & Access20 --> List22
    __Item17[/"__Item[17∈3]<br />ᐸ14ᐳ"\]:::itemplan
    ConnectionItems14 ==> __Item17
    __Item17 --> Access19
    __Item17 --> Access20
    Lambda23{{"Lambda[23∈3]<br />ᐸtoSpecifierᐳ"}}:::plan
    List22 --> Lambda23
    Access24{{"Access[24∈3]<br />ᐸ23.__typenameᐳ"}}:::plan
    Lambda23 --> Access24
    Access25{{"Access[25∈3]<br />ᐸ23.idᐳ"}}:::plan
    Lambda23 --> Access25
    PgSelect26[["PgSelect[26∈5]<br />ᐸfirst_party_vulnerabilitiesᐳ<br />ᐳFirstPartyVulnerability<br />More deps:<br />- Object[11]"]]:::plan
    Access25 --> PgSelect26
    First30{{"First[30∈5]^"}}:::plan
    PgSelectRows31[["PgSelectRows[31∈5]^"]]:::plan
    PgSelectRows31 --> First30
    PgSelect26 --> PgSelectRows31
    PgSelectSingle32{{"PgSelectSingle[32∈5]^<br />ᐸfirst_party_vulnerabilitiesᐳ"}}:::plan
    First30 --> PgSelectSingle32
    PgClassExpression41{{"PgClassExpression[41∈5]^<br />ᐸ__first_pa...ies__.”id”ᐳ"}}:::plan
    PgSelectSingle32 --> PgClassExpression41
    PgClassExpression43{{"PgClassExpression[43∈5]^<br />ᐸ__first_pa...s__.”name”ᐳ"}}:::plan
    PgClassExpression41 o--o PgClassExpression43
    PgClassExpression45{{"PgClassExpression[45∈5]^<br />ᐸ__first_pa...vss_score”ᐳ"}}:::plan
    PgClassExpression43 o--o PgClassExpression45
    PgSelect34[["PgSelect[34∈6]<br />ᐸthird_party_vulnerabilitiesᐳ<br />ᐳThirdPartyVulnerability<br />More deps:<br />- Object[11]"]]:::plan
    Access25 --> PgSelect34
    First38{{"First[38∈6]^"}}:::plan
    PgSelectRows39[["PgSelectRows[39∈6]^"]]:::plan
    PgSelectRows39 --> First38
    PgSelect34 --> PgSelectRows39
    PgSelectSingle40{{"PgSelectSingle[40∈6]^<br />ᐸthird_party_vulnerabilitiesᐳ"}}:::plan
    First38 --> PgSelectSingle40
    PgClassExpression42{{"PgClassExpression[42∈6]^<br />ᐸ__third_pa...ies__.”id”ᐳ"}}:::plan
    PgSelectSingle40 --> PgClassExpression42
    PgClassExpression44{{"PgClassExpression[44∈6]^<br />ᐸ__third_pa...s__.”name”ᐳ"}}:::plan
    PgClassExpression42 o--o PgClassExpression44
    PgClassExpression46{{"PgClassExpression[46∈6]^<br />ᐸ__third_pa...vss_score”ᐳ"}}:::plan
    PgClassExpression44 o--o PgClassExpression46
    PgClassExpression47{{"PgClassExpression[47∈6]^<br />ᐸ__third_pa...ndor_name”ᐳ"}}:::plan
    PgClassExpression46 o--o PgClassExpression47
    PgClassExpression49{{"PgClassExpression[49∈6]^<br />ᐸ”polymorph...ilities__)ᐳ"}}:::plan
    PgClassExpression47 o--o PgClassExpression49

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgUnionAll8,Access9,Access10,Object11,Connection12,ConnectionItems14 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item17,Access19,Access20,List22,Lambda23,Access24,Access25 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgSelect26,First30,PgSelectRows31,PgSelectSingle32,PgClassExpression41,PgClassExpression43,PgClassExpression45 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgSelect34,First38,PgSelectRows39,PgSelectSingle40,PgClassExpression42,PgClassExpression44,PgClassExpression46,PgClassExpression47,PgClassExpression49 bucket6

